package com.ruipengkj.component.jdialog;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.LayoutManager;
import java.awt.TexturePaint;

import javax.swing.JPanel;

import com.ruipengkj.commons.util.Util;

public class BorderJPanel extends JPanel {

	private static final long serialVersionUID = 1L;
	private Color c = new Color(248, 177, 61);
	private Color color = new Color(246, 163, 49);
	
	public BorderJPanel() {}
	
	public BorderJPanel(LayoutManager layout) {
		super(layout);
	}

	private TexturePaint paint =null;
	public BorderJPanel(Image image){
		paint=Util.createTexturePaint(image);
	}
	
	@Override
	protected void paintComponent(Graphics g) {
		if (paint != null) {
			Graphics2D g2d = (Graphics2D) g;
			g2d.setPaint(paint);
			g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
		} else {
			super.paintComponent(g);
		}
	}
	@Override
	public void paint(Graphics g) {
		super.paint(g);
		g.setColor(color);
		g.fillRect(0, 0, 4, this.getHeight());
		g.fillRect(this.getWidth()-4, 0, 4, this.getHeight());
		g.setColor(c);
		g.fillRect(0, this.getHeight()-3, this.getWidth(), 4);
	}
}
